배송 |
---|
상품 정보 | 가격 | 삭제 |
---|---|---|
아두이노 이더넷 Ethernet ENC28J60 모듈 | ||
TOTAL PRICE(수량) 0 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | #include <EtherCard.h> //0은 DHCP, 1은 Static으로 설정 #define STATIC 0 // set to 1 to disable DHCP (adjust myip/gwip values below) //Static IP 일 경우 설정 #if STATIC // ethernet interface ip address static byte myip[] = { 192,168,0,6 }; // gateway ip address static byte gwip[] = { 192,168,0,204 }; #endif // ethernet mac address - must be unique on your network static byte mymac[] = { 0x74,0x69,0x69,0x2D,0x30,0x31 }; byte Ethernet::buffer[500]; // tcp/ip send and receive buffer //요청이 왔을 경우 뿌려줄 HTML 소스 const char page[] PROGMEM = "HTTP/1.0 503 Service Unavailable\r\n" "Content-Type: text/html\r\n" "Retry-After: 600\r\n" "\r\n" "<html>" "<head><title>" "Ethernet Module Test_EDUINO" "</title></head>" "<body>" "<h3>Eduino Ethernet Module Test</h3>" "<p><em>" "Let's Play With Arduino<br />" "</em></p>" "</body>" "</html>" ; void setup(){ Serial.begin(57600); Serial.println("\n[backSoon]"); if (ether.begin(sizeof Ethernet::buffer, mymac) == 0) Serial.println( "Failed to access Ethernet controller"); #if STATIC ether.staticSetup(myip, gwip); #else if (!ether.dhcpSetup()) Serial.println("DHCP failed"); #endif ether.printIp("IP: ", ether.myip); ether.printIp("GW: ", ether.gwip); ether.printIp("DNS: ", ether.dnsip); } #define STATIC 0 // set to 1 to disable DHCP (adjust myip/gwip values below) void loop(){ //웹브라우저의 요청이 들어왔을 경우 page 의 내용을 보내줌 // wait for an incoming TCP packet, but ignore its contents if (ether.packetLoop(ether.packetReceive())) { memcpy_P(ether.tcpOffset(), page, sizeof page); ether.httpServerReply(sizeof page - 1); } } | cs |